package com.cino.demos.sourceCode.AOPdemo;

import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        System.out.println("🎯 AOP拦截器链示例");
        System.out.println("==================");
        
        // 1. 创建真实对象
        UserService realService = new UserServiceImpl();
        
        // 2. 创建拦截器链
        List<MethodInterceptor> interceptors = Arrays.asList(
            new BeforeAdviceInterceptor("日志通知"),
            new AroundAdviceInterceptor("性能监控"),
            new BeforeAdviceInterceptor("权限检查")
        );
        
        // 3. 创建AOP代理对象
        UserService proxy = AopProxyFactory.createAopProxy(
            UserService.class, realService, interceptors
        );
        
        System.out.println("📋 代理对象创建完成: " + proxy.getClass());
        System.out.println();
        
        // 4. 调用代理方法
        System.out.println("1️⃣ 调用 findUserById(123):");
        String user = proxy.findUserById(123L);
        System.out.println("📄 返回结果: " + user);
        System.out.println();
        
        System.out.println("2️⃣ 调用 saveUser('李四'):");
        proxy.saveUser("李四");
        System.out.println("✅ 方法调用完成");
    }
}